#include "widget.h"
#include "./ui_widget.h"

#include <QPushButton>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    button = new QPushButton(this);
    // button->move(300, 300);
    button->setText("点击");

    connect(button, &QPushButton::clicked, this, &Widget::MyClick);

    connect(this, &Widget::MySignal, this, &Widget::MyHandle);

    // connect(button, SIGNAL(QPushButton::clicked()), this, SLOT(MyClick()));

    // connect(button, SIGNAL(clicked()), this, SLOT(MyClick()));

    // QPushButton* button = new QPushButton(this);
    // button->setText("点击");
    // button->move(200, 200);


    // connect(button, SIGNAL(QPushButton::clicked()), this, SLOT(&Widget::MyHandle()));
}

Widget::~Widget()
{
    delete ui;
}

void Widget::MyClick()
{
    this->setWindowTitle("按钮已被点击");
    emit MySignal("test1", "test2");

    // button->move(200, 200);
    // this->move(100, 100);
}

void Widget::MyHandle(QString text)
{
    qDebug() << text;
}

// void Widget::MyHandle()
// {
//     this->setWindowTitle("按钮已被点击");
// }
